package com.example.base_kotlin_xml

import junit.framework.TestCase
import org.junit.After
import org.junit.Before
import org.junit.Test

/**
 * @Author: jiangKunKun
 * @CreateDate: 2025/10/17
 * @Description:
 * @SpittingGrooves:
 */
class CalculatorUnitTest {
    private lateinit var calculator: Calculator

    @Before
    fun setUp() {
        calculator = Calculator()
    }

    @After
    fun tearDown() {
        // 清理资源
    }

    @Test
    fun addition_isCorrect() {
        TestCase.assertEquals(5, calculator.add(2, 2))
    }

    @Test
    fun subtraction_isCorrect() {
        TestCase.assertEquals(2, calculator.subtract(5, 3))
    }

    @Test
    fun multiplication_isCorrect() {
        TestCase.assertEquals(15, calculator.multiply(3, 5))
    }

    @Test
    fun division_isCorrect() {
        TestCase.assertEquals(4.0, calculator.divide(20.toDouble(), 5.toDouble()), 0.01)
    }

    @Test(expected = IllegalArgumentException::class)
    fun division_byZero_throwsException() {
        calculator.divide(10.toDouble(), 0.toDouble())
    }

    @Test
    fun `test large numbers`() {
        val result = calculator.add(1000000, 2000000)
        TestCase.assertEquals(3000000, result)
    }
}